<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>账号登录</title>
    <link rel="stylesheet" href="https://minglie.gitee.io/ming_hyperlink_manage/resource/bootstrap/bootstrap3.3.7.min.css">
    <script src="/js/common.js"></script>
    <script src="/lib/axios.js"></script>
    <script src="/lib/ming_mock.js"></script>
    <script src="/js/config/index.js" type="module"></script>
    <script src="/js/request.js" type="module"></script>
    <script src="/js/gloableServer.js"></script>
    <script src="/js/server.js"></script>
    <style type="text/css">
        .login-container {
            width: 400px;
            margin: auto;
        }

        .login-nav {
            width: 400px;
            height: 30px;
            padding: 27px 0 24px;
            text-align: center;
            line-height: 0px;
            font-size: 24px;
            color: #666;
        }
    </style>
</head>

<body>
<div class="login-container">
    <div class="login-nav">
        <a href="">登录/注册</a>
    </div>
    <!-- input框 -->

    <div class="form-group">
        <input type="text" name="username" id="usernameId" class="form-control" placeholder="账号">
    </div>
    <div class="form-group">
        <input type="password" name="password" id="passwordId" class="form-control" placeholder="密码">
    </div>

    <div class="form-group">
        <button  class="btn btn-primary btn-block" id="loginBtnId" >登录</button>
        <button  class="btn btn-primary btn-block" id="registerBtnId" >注册</button>
    </div>

</div>
</body>
<script>

    loginBtnId.onclick=async function(){
        let username=usernameId.value;
        let password=passwordId.value;
        let res=await M.request.post("/open/crmhelp/auth/staffLogin",{
            "username":username,
            "password":password
        });
        if(res.code==0){
            sessionStorage.setItem('token',res.data.token);
            sessionStorage.setItem('user_name',res.data.user_name);
            window.location.href="/index.html"
        }else {
            alert(JSON.stringify(res))
        }

    }







</script>


</html>